package framework.drawer.swing.gui;

import java.awt.Component;
import java.util.ArrayList;
import java.util.List;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;

import framework.view.BaseMenuItem;

public class EditorToolsPanel extends JPanel implements ISideBarElement {
    private static final int FULLSIZE_SCALING_FACTOR = 1;
    
	private List<JButton> buttons;
    private String title;

    public EditorToolsPanel(String title, List<BaseMenuItem> menuItems, List<JButton> jButtons) {
        super();
        
        this.title = title;
        this.buttons = new ArrayList<JButton>();
        for(JButton b : jButtons) {
//        	b.setUI(new IconButtonUI(FULLSIZE_SCALING_FACTOR));
        	buttons.add(b);
        }
        /*for(BaseMenuItem item : menuItems) {
        	buttons.add(createButton(item));
        }*/
        this.setUI(new EditorToolsPanelUI(this));
    }
    
    private JButton createButton(BaseMenuItem item) {
    	JButton button = new JButton();
        //ImageIcon icon = new ImageIcon(this.getClass().getResource("./icons/22x22/undo.png"));
    	ImageIcon icon = new ImageIcon(this.getClass().getResource(item.getImagePath()));
        button.setIcon(icon);
        if(item.getCaption() != null)
        	button.setText(item.getCaption());
        
        return button;
    }

    public String getTitle() {
        return this.title;
    }

    public Component getAWTComponent() {
        return this;
    }
    
    public List<JButton> getButtons() {
        return buttons;
    }

	public void install() {
		// TODO Auto-generated method stub	
	}
}
